package com.etone.app.crawler.portals;

import com.etone.app.crawler.portals.common.TaskQueue;
import com.etone.app.crawler.portals.entity.Task;
import com.etone.app.crawler.portals.handle.TaskHandleThread;
import java.io.IOException;
import org.apache.ibatis.io.Resources;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

/**
 *
 * @author <a href="mailto:cbean@qq.com">CowboyBean</a>
 * @date Mar 14, 2014
 * @version $$Reversion$$
 */
public class Startup {
    
    private static final Logger logger = Logger.getLogger(Startup.class);

    public static void main(String[] args) {

        String url = "http://m.elong.com/";
        String userAgent = "User-Agent:Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5";

        initLog();
        
        try {
            
            Task task = new Task();
            task.setLevel(1);
            task.setServiceName("腾讯");
            task.setServiceUrl("http://3gqq.qq.com");
            task.setSrcUrl(" ");
            task.setText("腾讯");
            task.setUrl("http://3gqq.qq.com");
            TaskQueue.putTask(task);

            new TaskHandleThread().start();

        } catch (Exception ex) {
            ex.printStackTrace();
        }

    }

    public static void initLog() {
        String resource = "config/log4j/log4j.properties";
        try {
            PropertyConfigurator.configure(Resources.getResourceAsProperties(resource));
            logger.info("加载日志配置成功！");
        } catch (IOException ex) {
            System.out.println("加载日志配置失败！");
        }
    }
    
    
}
